home *** CD-ROM | disk | FTP | other *** search
Text File | 1997-07-16 | 2.3 KB | 79 lines | [TEXT/CWIE] |
- // ===========================================================================
- // MyUtils.h ©1995-97 Timo Eloranta All rights reserved.
- // ===========================================================================
- // MyUtils.cp (press Command-Tab to open the associated source file)
-
- #pragma once
-
- #include <PP_Types.h>
-
- void ToggleMenuItem( CommandT inCommand,
- ResIDT inStringID );
-
- Boolean MyPtInRect( Int16 inX, Int16 inY, const Rect *inRect );
-
- pascal OSErr PlayOneSnd( ResIDT inSoundID, Boolean inAsync );
-
- Int16 RangedRdm ( Int16 inMin, Int16 inMax );
- Int16 FastRandom ( Int16 inRange );
- Boolean RandomBool ( void );
-
- void LineFromTo ( Int16 xFrom, Int16 yFrom, Int16 xTo, Int16 yTo);
-
-
- // ===========================================================================
- // • Inline Functions
- // ===========================================================================
-
- // ---------------------------------------------------------------------------
- // • RangedRdm
- //
- // Called by: CGraphDrawing::Mutate
- // CGraphDrawing::ThreeConnectedNodes
- // CGraphNodes::Initialize
- // CGraphNodes::SingleMutate etc.
- // CPopulation::SetUpEdges
- // CPopulation::SelectOne etc.
- // ---------------------------------------------------------------------------
-
- inline Int16
- RangedRdm( Int16 inMin, Int16 inMax)
- {
- Int16 theRange = (inMax - inMin) + 1; // OVERFLOW POSSIBLE
- // IF USED WITH BIG VALUES !!!
-
- return inMin + FastRandom( theRange );
- }
-
- // ---------------------------------------------------------------------------
- // • RandomBool
- //
- // Called by: CGraphDrawing::EdgeMutation
- // CGraphDrawing::TwoEdgeMutation
- // CGraphNodes::MoveEdge
- // CGraphNodes::Move3ConnectedNodes
- // CPopulation::DoCrossover
- // CPopulation::DoRectCrossover
- // ---------------------------------------------------------------------------
-
- inline Boolean
- RandomBool( void )
- {
- return FastRandom( 2 );
- }
-
- // ---------------------------------------------------------------------------
- // • LineFromTo
- //
- // Called by: CEdge::Draw
- // CGraphPane::DrawGrid
- // ---------------------------------------------------------------------------
-
- inline void
- LineFromTo (Int16 xFrom, Int16 yFrom,
- Int16 xTo, Int16 yTo)
- {
- ::MoveTo( xFrom, yFrom );
- ::LineTo( xTo, yTo );
- }
-